
*	************************************************************************
* 	File-Name: 	prep.do
*	Log-file:	n/a
*	Date:  		7 November 2019
*	Author:		Patrick Bayer
*	Paper:		Patrick Bayer, Ryan Kennedy, Joonseok Yang, and Johannes Urpelainen
*				The Need For Impact Evaluation in Electricity Access Research
*	Journal:	Energy Policy
*	Data Used:  ./Impact_data.xls
*	Output		n/a
*	Purpose:   	file prepares raw data for analysis
*	************************************************************************


*	************************************************************************
*   Techincal disclaimer:
*   All files/ data were created/ analysed in Stata/SE 14.2 on Windows 10, 64 bit
*	Machine: Intel(R) Core(TM) i7-4650U CPU @ 1.70Ghz 2.30Ghz with 8GB RAM
*	************************************************************************

clear all
set more off, permanently

*	************************************************************************
*	A. Load data and setup
*	************************************************************************

import excel "./Impact_data.xlsx", sheet("Sheet1") firstrow

*	************************************************************************
*	B. Clean up, create and label variables
*	************************************************************************

* Method variable

replace Method="Observational" if Method=="Observational "

gen temp = .
replace temp=1 if Method=="Observational"
replace temp=2 if Method=="Experiment"
drop Method
rename temp Method
label define mlabel 1 "Observational" 2 "Experiment"
label value Method mlabel
label variable Method "Method type"

* MethodDetail variable

gen temp = .
replace temp=1 if MethodDetail=="Descriptive"
replace temp=2 if MethodDetail=="IV"
replace temp=3 if DID=="Yes"
replace temp=4 if MethodDetail=="Experiment"
drop MethodDetail
rename temp MethodDetail
label define mdlabel 1 "Descriptive" 2 "IV" 3 "DID" 4 "Experiment"
label value MethodDetail mdlabel
label variable MethodDetail "Method type (detailed)"

order Method MethodDetail, after(Referred)

* Technology variable

gen temp = . 
replace temp=1 if Technology=="grid"
replace temp=2 if Technology=="off-grid"
drop Technology
rename temp Technology
label define tlabel 1 "grid" 2 "off-grid"
label value Technology tlabel
label variable Technology "Technology type"

order Technology, after(Country)

* Variable variable

replace Variable=Variable+1
replace Variable=0 if Variable==.
label define vlabel 0 "Not assessed" 1 "Similar variable" 2 "Exact variable"
label value Variable vlabel
label variable Variable "Outcome variable (indicator)"

* Outcome variable

gen temp=.
replace temp=1 if Outcome=="Business creation"
replace temp=2 if Outcome=="Education"
replace temp=3 if Outcome=="Energy expenditures"
replace temp=4 if Outcome=="Household income/expenditure"
replace temp=5 if Outcome=="Household savings"

drop Outcome
rename temp Outcome
label define olabel 1 "Business creation" 2 "Education" 3 "Energy expenditure" 4 "HH income" 5 "HH savings"
label value Outcome olabel
label variable Outcome "Outcome variable"
order Outcome, after(Variable)

* Results variable

replace Results="negative" if Results=="negative "
gen temp=.
replace temp=-1 if Results=="negative"
replace temp=0 if Results=="none"
replace temp=1 if Results=="positive"

drop Results
rename temp Results

label define rlabel -1 "negative" 0 "none" 1 "positive"
label value Results rlabel
label variable Results "Results"

order Results, after(Outcome)

* Impact variable

gen temp=.
replace temp=-1 if Impact=="negative"
replace temp=0 if Impact=="neutral"
replace temp=1 if Impact=="positive"

drop Impact
rename temp Impact
label define ilabel -1 "negative" 0 "neutral" 1 "positive"
label value Impact ilabel
label variable Impact "Impact"

order Impact, after(Results)

*	************************************************************************
*								END OF DO FILE 
*	************************************************************************



